/*
 * WorkerManager.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef WORKERMANAGER_H_
#define WORKERMANAGER_H_

#include <iostream>
#include "Worker.h"
using namespace std;

class WorkerManager {
protected:
	WorkerManager();
private:
	static WorkerManager * manager;
	static bool initialized;
	static vector<double> original_configuration;
	static CellModel * template_cell_model;
	static SubstrateModel * template_substrate_model;
	static Comparator * template_comparator;
	static unsigned int n_threads;

	vector<Worker*> worker;
	Worker * findOrCreateFreeWorker();

public:
	static WorkerManager * getInstance();
	static void initialize(CellModel * TEMPLATE_CELL_MODEL, SubstrateModel * TEMPLATE_SUBSTRATE_MODEL, Comparator * TEMPLATE_COMPARATOR, unsigned int N_THREADS);
	Worker * getWorker(vector<double> parameters, int ID);
	Worker * getWorker(vector<double> parameters, vector<double> initial_configuration, int ID);
	CellModel * get_template_cell_model(){ return template_cell_model; };
	SubstrateModel * get_template_substrate_model() { return template_substrate_model; };
	Comparator * get_template_comparator() { return template_comparator; };
};


#endif /* WORKERMANAGER_H_ */
